package controller;

import java.sql.ResultSet;
import db.DBSportsExercise;
import db.DBWorkOut;

import model.SportsExercise;
import model.WorkOut;


public class WorkOutController {

private int currentWorkOutId;
	
	private static WorkOutController workOutController = null;
    /** Making the class private as per the singleton pattern */
    private WorkOutController(){
    
    }
    /** Creating an instance of the class*/
    public static WorkOutController getInstance(){
            if(workOutController == null){
            	workOutController = new WorkOutController();
            }
            return workOutController;
    }

	public int findSportsExerciseId(String type, double distance){
		DBSportsExercise DBexercise = new DBSportsExercise();
		SportsExercise exercise = new SportsExercise();
		exercise = DBexercise.findSportsExercise(type, distance, true);

		return exercise.getId();

	}

	public void createWorkOut(String date, Double energy,String note,String time, Boolean isCompleted,String userId,int exerciseId){
		
		
		WorkOut workOut = new WorkOut();
		workOut.setDate(date);
		workOut.setEnergy(energy);
		workOut.setNote(note);
		workOut.setTime(time);
		workOut.setIsCompleted(isCompleted);

		DBWorkOut dbworkout = new DBWorkOut();
		dbworkout.insertWorkOut(workOut,userId, exerciseId);


	}
	public ResultSet getUserWorkOuts(String userId){

		DBWorkOut dbworkout = new DBWorkOut();
		ResultSet rs = dbworkout.getUserWorkOuts(userId);
		return rs;

	}
	public int getCurrentWorkOutId() {
		return currentWorkOutId;
	}
	public void setCurrentWorkOutId(int currentWorkOutId) {
		this.currentWorkOutId = currentWorkOutId;
	}
}
